﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>ComObjActive - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The ComObjActive function retrieves a running object that has been registered with OLE." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>ComObjActive</h1>

<p>检索已使用 OLE(对象连接与嵌入) 注册的运行中的对象.</p>
<pre class="Syntax">ComObject := <span class="func">ComObjActive</span>(CLSID)</pre>

<h2 id="Parameters">参数</h2>
<dl>

  <dt>CLSID</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>要检索的 COM 对象的 CLSID 或可读的 Prog ID.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#objects">对象</a></p>
<p>此函数返回正在运行的 COM 对象的<a href="../Concepts.htm#references-to-objects">引用</a>.</p>

<h2 id="Error_Handling">错误处理</h2>
<p>失败时抛出异常.</p>

<h2 id="Related">相关</h2>
<p><a href="ComObject.htm">ComObject</a>, <a href="ComObjCreate.htm">ComObjCreate</a>, <a href="ComObjGet.htm">ComObjGet</a>, <a href="ComObjConnect.htm">ComObjConnect</a>, <a href="ComObjFlags.htm">ComObjFlags</a>, <a href="ObjAddRef.htm">ObjAddRef/ObjRelease</a>, <a href="ComObjQuery.htm">ComObjQuery</a>, <a href="http://msdn.microsoft.com/en-us/library/ms221467.aspx">GetActiveObject (MSDN)</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExWord">
<p><a href="#ExWord">#1</a>: 如果 Microsoft Word 正在运行, 显示其活动文档的路径.</p>
<pre>word := ComObjActive("<a href="http://msdn.microsoft.com/en-us/library/office/ff838565">Word.Application</a>")
if !word
    MsgBox "Word isn't open."
else
    MsgBox word.<a href="http://msdn.microsoft.com/en-us/library/office/ff837737">ActiveDocument</a>.<a href="http://msdn.microsoft.com/en-us/library/office/ff821285">FullName</a></pre>
</div>

</body>
</html>